Skip to content

Conversation

@stephanmeesters
Copy link

@stephanmeesters stephanmeesters commented Dec 22, 2025

Goal of this refactor PR

These functions all refer to GameLogic

  1. Check that reset is always called before startNewGame
  2. Remove the code in startNewGame that is already handled in reset
  3. GameInfo appears to have an unnecessary local variable, use TheGameInfo everywhere
  4. Call reset and the end of init as this code was duplicated

Overview of startNewGame

  1. in SP, set up the load screen and return on the first call so the real start happens from the update loop (in case of a new game)
  2. Initialize defaults and globals; resolve the active GameInfo (network/skirmish/challenge/replay) and copy per-game restrictions (e.g., superweapon limits).
  3. Fill in random sides/colors/start positions, bring up the load screen, and tear down any background UI.
  4. Load map.ini, load the terrain map, and prepare the side list for MP/skirmish.
  5. Build player sides/teams from slots (plus a replay observer), reset team/player lists, and notify the script engine of the new map.
  6. Configure victory conditions, radar, world extents, partition manager, ghost objects, and terrain newMap.
  7. Spawn bridge landmarks, refresh radar/pathfinding, and reveal shroud per observer/MP rules.
  8. Instantiate map objects (trees/props/logic objects), assign teams/positions, update behaviors, and register with pathfinding.
  9. Place initial network buildings/units, preload assets, set up the tactical view and initial camera position.
  10. Finalize relationships/skill points, drive load progress and fade-out, switch UI/control bar to the target mode, and clear loading state.

@stephanmeesters stephanmeesters force-pushed the refactor-gamelogic-startnewgame branch 3 times, most recently from 8cb26a4 to 78ea6d6 Compare December 23, 2025 15:50
@stephanmeesters stephanmeesters marked this pull request as ready for review December 23, 2025 15:53
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor makes sense. New comments need removal.

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing labels Jan 1, 2026
@stephanmeesters stephanmeesters force-pushed the refactor-gamelogic-startnewgame branch from 78ea6d6 to 322bbd5 Compare January 1, 2026 18:12
@stephanmeesters
Copy link
Author

Removed the docs commit containing the comments

The info comment was added to describe the exact situation when TheGameInfo is null , not just to say it can be null

@xezon xezon changed the title refactor(logic): Start new game and reset refactor(logic): Simplify code in GameLogic's init, reset, startNewGame Jan 2, 2026
@xezon xezon merged commit ae22809 into TheSuperHackers:main Jan 2, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants